package com.github.fancyideas.utils;

public class ResultBuilder {

    private static final String SUCCESS = "SUCCESS";
    private static final String ERROR = "ERROR";


    private ResultBuilder() {

    }

    public static Result build() {
        return new Result();
    }

    // build error message
    public static Result buildError(String errorSign, Object data) {
        return new Result()
                .setSign(errorSign)
                .setData(data);
    }

    public static Result buildError(Object data) {
        return new Result()
                .setSign(ERROR)
                .setData(data);
    }

    public static String buildErrorJson(String errorSign, Object data) {
        return new Result()
                .setSign(errorSign)
                .setData(data)
                .toJsonString();
    }

    public static String buildErrorJson(Object data) {
        return new Result()
                .setSign(ERROR)
                .setData(data)
                .toJsonString();
    }

    // build success message
    public static Result buildSuccess(String successSign, Object data) {
        return new Result()
                .setSign(successSign)
                .setData(data);
    }

    public static Result buildSuccess(Object data) {
        return new Result()
                .setSign(SUCCESS)
                .setData(data);
    }

    public static String buildSuccessJson(String errorSign, Object data) {
        return new Result()
                .setSign(errorSign)
                .setData(data)
                .toJsonString();
    }

    public static String buildSuccessJson(Object data) {
        return new Result()
                .setSign(SUCCESS)
                .setData(data)
                .toJsonString();
    }

}
